package com.hp.springbootwebflux.util;

import com.hp.springbootwebflux.exception.CheckException;

import java.util.stream.Stream;

/**
 * @author dongxing
 **/
public class CheckUtil {


    private final static String[] INVALID_NAMES = {"admin", "guanliyuan"};

    /**
     *
     * 效验名字是否合法,不成功抛出异常
     *
     * @param value
     */
    public static void checkNames(String value) {
        Stream.of(INVALID_NAMES).filter(name->value.equalsIgnoreCase(name))
                .findAny().ifPresent(name->{
            throw new CheckException("name", value
            );
        });
    }

}
